---
sidebar_label: Metadata format
sidebar_position: 3
description: Hasura Metadata file format reference
keywords:
  - hasura
  - docs
  - metadata
  - file format
---

import TOCInline from '@theme/TOCInline';

# Metadata Format Reference (config v2)

## Introduction

With `config v2`, the Metadata that is exported from the server by the CLI is a directory of multiple files.

:::info Note

For `config v1`, see
[Metadata file format reference (config v1)](/migrations-metadata-seeds/legacy-configs/config-v1/reference/metadata-file-format.mdx).

:::

## Metadata directory format

The following files will be generated in the `metadata/` directory of your project:

<TOCInline toc={toc} filterTOC={'metadata-directory-format'} />

:::info Note

The output of the [export_metadata](/api-reference/metadata-api/manage-metadata.mdx#metadata-export-metadata) metadata
API is a JSON version of the Metadata files.

:::

### actions.graphql

The `actions.graphql` file contains all the [actions](/actions/overview.mdx) definitions and
[custom type](/actions/types.mdx) definitions.

**Example**: A query action called `greet` and two custom types called `SampleInput` and `SampleOutput`.

```graphql
type Query {
  greet(arg1: SampleInput!): SampleOutput
}
input SampleInput {
  username: String!
}
type SampleOutput {
  greetings: String!
}
```

### actions.yaml

The `actions.yaml` file contains Metadata related to [Actions](/actions/overview.mdx).

**Example**: An action called `greet` with the `handler` set to `<base_url>/greet` and two custom types called
`SampleInput` and `SampleOutput`.

```yaml
actions:
  - name: greet
    definition:
      kind: ''
      handler: <base_url>/greet
      forward_client_headers: true
      headers:
        - value: application/json
          name: Content-Type
custom_types:
  enums: []
  input_objects:
    - name: SampleInput
  objects:
    - name: SampleOutput
  scalars: []
```

**Example**: Same example as above but with the base URL of the `handler` passed as an environment variable.

```yaml
actions:
  - name: greet
    definition:
      kind: ''
      handler: '{{ACTION_BASE_URL}}/greet'
      forward_client_headers: true
      headers:
        - value: application/json
          name: Content-Type
custom_types:
  enums: []
  input_objects:
    - name: SampleInput
  objects:
    - name: SampleOutput
  scalars: []
```

### allow_list.yaml

The `allow_list.yaml` file contains the Metadata related to the [allow list](/security/allow-list.mdx).

**Example**: A query collection called `allowed-queries` set as the allow-list.

```yaml
- collection: allowed-queries
```

### cron_triggers.yaml

The `cron_triggers.yaml` file contains Metadata related to [cron triggers](/scheduled-triggers/create-cron-trigger.mdx).
The `webhook` can be an HTTP endpoint or an environment variable containing the HTTP endpoint.

**Example**: A cron trigger called `test-trigger`.

```yaml
- name: test-trigger
webhook: <webhook-url>
schedule: 0 12 * * 1-5
include_in_metadata: true
payload: {}
retry_conf:
  num_retries: 1
  timeout_seconds: 60
  tolerance_seconds: 21600
  retry_interval_seconds: 10
```

:::info Note

The Metadata about a cron trigger will not be stored if `Include this trigger in Hasura Metadata` is disabled in the
advanced option of `events` on the Console or `include_in_metadata` is passed as `false` via the API.

:::

### functions.yaml

Contains the Metadata related to [custom functions](/schema/postgres/custom-functions.mdx).

**Example**: A custom SQL function called `search_books`.

```yaml
- function:
  schema: public
  name: search_books
```

### query_collections.yaml

The `query_collections.yaml` file contains Metadata information about
[query collections](/api-reference/metadata-api/query-collections.mdx).

**Example**: A query collection called `sample-collection` which contains two queries `test` and `test2`.

```yaml
- name: sample-collection
  definition:
    queries:
      - name: test
        query: |-
          query test {
            books {
              id
              author_id
              title
            }
          }
      - name: test2
        query: |-
          query test2 {
              authors{
                  id
                  author_name
              }
          }
```

### remote_schemas.yaml

The `remote_schemas.yaml` file contains the Metadata related to [Remote Schemas](/remote-schemas/overview.mdx).

**Example**: A Remote Schema called `my-remote-schema` with URL `<remote-schema-url>`.

```yaml
- name: my-remote-schema
  definition:
    url: <remote-schema-url>
    timeout_seconds: 40
```

**Example**: A Remote Schema called `my-remote-schema` with URL passed as environment variable.

```yaml
- name: my-remote-schema
  definition:
    url_from_env: REMOTE_SCHEMA
    timeout_seconds: 40
```

### tables.yaml

The `tables.yaml` file contains Metadata related to [tables](/schema/postgres/tables.mdx).

**Example**: Two tables called `authors` and `books` including relationships and an Event Trigger defined on the
`authors` table.

```yaml
- table:
    schema: public
    name: authors
  insert_permissions:
    - role: user
      permission:
        check:
          id:
            _eq: X-Hasura-User-Id
        columns:
          - name
        backend_only: false
  select_permissions:
    - role: user
      permission:
        columns:
          - id
          - name
        filter:
          id:
            _eq: X-Hasura-User-Id
  array_relationships:
    - name: books
      using:
        foreign_key_constraint_on:
          column: author_id
          table:
            schema: public
            name: books
  event_triggers:
    - name: event_test
      definition:
        enable_manual: false
        insert:
          columns: '*'
        delete:
          columns: '*'
        update:
          columns:
            - id
            - author_name
      retry_conf:
        num_retries: 1
        interval_sec: 10
        timeout_sec: 60
      webhook: <webhook_url>
- table:
    schema: public
    name: books
  insert_permissions:
    - role: user
      permission:
        check:
          id:
            _eq: X-Hasura-User-Id
        columns:
          - author_id
          - name
        backend_only: false
  select_permissions:
    - role: user
      permission:
        columns:
          - id
          - name
        filter:
          id:
            _eq: X-Hasura-User-Id
  object_relationships:
    - name: author
      using:
        foreign_key_constraint_on: author_id
```

### version.yaml

The `version.yaml` file contains the Metadata format version.

```yaml
version: 2
```
